<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
use Jedrzej\Pimpable\PimpableTrait;

class UserNotice extends Model
{
    use HasFactory;
    use PimpableTrait;
    use SoftDeletes;

    /**
     * 可执行搜索的字段
     */
    public $searchable = [
        'user_id',
        'type',
        'sender_user_id',
        'title',
        'is_send',
    ];

    /**
     * 可以批量赋值的字段
     */
    public $fillable = [
        'user_id',
        'type',
        'sender_user_id',
        'title',
        'content',
        'is_send'
    ];

    /**
     * 默认使用倒叙的字段
     */
    public $defaultSortCriteria = [
        'id,desc',
    ];

    /**
     * 通知消息关联用户的id
     */
    public function user()
    {
        return $this->hasMany(User::class,'id','id');
    }

}
